package com.atguigu.rabbitmq.eight;

import com.atguigu.rabbitmq.utils.RabbitMqUtils;
import com.rabbitmq.client.Channel;
import com.rabbitmq.client.DeliverCallback;



/**
 * @author: like
 * @Date: 2021/07/19 7:10
 */
public class Consumer02 {


    //死信交换机的名称
    public static final String DEAD_EXCHANGE = "dead_exchange";
    //死信队列的名称
    public static final String DEAD_QUEUE = "dead_queue";


    public static void main(String[] args) throws Exception {
        Channel channel = RabbitMqUtils.getChannel();

//        //声明交换机
//        channel.exchangeDeclare(DEAD_EXCHANGE, BuiltinExchangeType.DIRECT);
//        //声明队列
//        channel.queueDeclare(DEAD_QUEUE, false, false, false, null);
//        channel.queueBind(DEAD_QUEUE, DEAD_EXCHANGE, "lisi");

        System.out.println("等待接收死信消息........... ");

        //接收消息
        DeliverCallback deliverCallback = (consumerTag, delivery) -> {

            System.out.println("Consumer02接收到的消息是：" + new String(delivery.getBody(), "UTF-8"));
        };
        channel.basicConsume(DEAD_QUEUE, true, deliverCallback, consumerTag -> {
        });
    }

}
